package bb.lanxing.nav;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
import android.os.RemoteException;
import bb.lanxing.model.json.RouteStep;

public interface INavigationServiceCallback extends IInterface {
    void onArrived() throws RemoteException;

    void onNavFailed(int code) throws RemoteException;

    void onNavStart() throws RemoteException;

    void onNavUpdate(int type, String msg, double distance) throws RemoteException;

    void onNavYaw(RouteStep step) throws RemoteException;

    void onYawBack(RouteStep step) throws RemoteException;

    public static abstract class Stub extends Binder implements INavigationServiceCallback {
        private static final String DESCRIPTOR = "bb.lanxing.nav.INavigationServiceCallback";
        static final int TRANSACTION_onNavStart = 1;
        static final int TRANSACTION_onNavUpdate = 2;
        static final int TRANSACTION_onNavYaw = 3;
        static final int TRANSACTION_onYawBack = 4;
        static final int TRANSACTION_onArrived = 5;
        static final int TRANSACTION_onNavFailed = 6;

        @Override
        public IBinder asBinder() {
            return this;
        }

        public Stub() {
            attachInterface(this, DESCRIPTOR);
        }

        public static INavigationServiceCallback asInterface(IBinder obj) {
            if (obj == null) {
                return null;
            }
            IInterface queryLocalInterface = obj.queryLocalInterface(DESCRIPTOR);
            if ((queryLocalInterface instanceof INavigationServiceCallback)) {
                return (INavigationServiceCallback) queryLocalInterface;
            }
            return new Proxy(obj);
        }

        @Override
        public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
            if (code == INTERFACE_TRANSACTION) {
                reply.writeString(DESCRIPTOR);
                return true;
            }
            switch (code) {
                case TRANSACTION_onNavStart -> {
                    data.enforceInterface(DESCRIPTOR);
                    onNavStart();
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onNavUpdate -> {
                    data.enforceInterface(DESCRIPTOR);
                    onNavUpdate(data.readInt(), data.readString(), data.readDouble());
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onNavYaw -> {
                    data.enforceInterface(DESCRIPTOR);
                    onNavYaw(data.readInt() != 0 ? RouteStep.CREATOR.createFromParcel(data) : null);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onYawBack -> {
                    data.enforceInterface(DESCRIPTOR);
                    onYawBack(data.readInt() != 0 ? RouteStep.CREATOR.createFromParcel(data) : null);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onArrived -> {
                    data.enforceInterface(DESCRIPTOR);
                    onArrived();
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onNavFailed -> {
                    data.enforceInterface(DESCRIPTOR);
                    onNavFailed(data.readInt());
                    reply.writeNoException();
                    return true;
                }
                default -> {
                    return super.onTransact(code, data, reply, flags);
                }
            }
        }

        public static class Proxy implements INavigationServiceCallback {
            public static INavigationServiceCallback sDefaultImpl;
            private IBinder mRemote;

            Proxy(IBinder remote) {
                this.mRemote = remote;
            }

            @Override
            public IBinder asBinder() {
                return this.mRemote;
            }

            @Override
            public void onNavStart() throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    if (!this.mRemote.transact(TRANSACTION_onNavStart, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onNavStart();
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }

            @Override
            public void onNavUpdate(int type, String msg, double distance) throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    obtain.writeInt(type);
                    obtain.writeString(msg);
                    obtain.writeDouble(distance);
                    if (!this.mRemote.transact(TRANSACTION_onNavUpdate, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onNavUpdate(type, msg, distance);
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }

            @Override
            public void onNavYaw(RouteStep step) throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    if (step != null) {
                        obtain.writeInt(1);
                        step.writeToParcel(obtain, 0);
                    } else {
                        obtain.writeInt(0);
                    }
                    if (!this.mRemote.transact(TRANSACTION_onNavYaw, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onNavYaw(step);
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }

            @Override
            public void onYawBack(RouteStep step) throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    if (step != null) {
                        obtain.writeInt(1);
                        step.writeToParcel(obtain, 0);
                    } else {
                        obtain.writeInt(0);
                    }
                    if (!this.mRemote.transact(TRANSACTION_onYawBack, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onYawBack(step);
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }

            @Override
            public void onArrived() throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    if (!this.mRemote.transact(TRANSACTION_onArrived, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onArrived();
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }

            @Override
            public void onNavFailed(int code) throws RemoteException {
                Parcel obtain = Parcel.obtain();
                Parcel obtain2 = Parcel.obtain();
                try {
                    obtain.writeInterfaceToken(Stub.DESCRIPTOR);
                    obtain.writeInt(code);
                    if (!this.mRemote.transact(TRANSACTION_onNavFailed, obtain, obtain2, 0) && Stub.getDefaultImpl() != null) {
                        Stub.getDefaultImpl().onNavFailed(code);
                    } else {
                        obtain2.readException();
                    }
                } finally {
                    obtain2.recycle();
                    obtain.recycle();
                }
            }
        }

        public static INavigationServiceCallback getDefaultImpl() {
            return Proxy.sDefaultImpl;
        }
    }
}